<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="../static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="../lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="../static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>密码修改</title>
<meta name="keywords" content="">
<meta name="description" content="">
</head>
<body>
<div class="page-container">
	<div class="form form-horizontal" id="form-admin-add">
		<div id="updateTypeDiv" class="row cl hide">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red"></span>修改类型：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<select id="updateType" class="input-text" style="width:100%;">
					<option value="0">登录密码</option>
					<option value="1">二级密码</option>
				</select>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red"></span>原始密码：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="password" class="input-text" autocomplete="off" value=""  id="oldPwd" name="" style="width:100%;">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red"></span>新密码：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="password" class="input-text" autocomplete="off" value=""  id="newPwd" name="" style="width:100;">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red"></span>确认密码：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="password" class="input-text" autocomplete="off" value=""  id="confirmNewPwd" name="" style="width:100;">
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<a href="javascript:;" onclick="updateAdminPwd();" class="btn btn-primary radius">&nbsp;&nbsp;修改&nbsp;&nbsp;</a>
			</div>
		</div>
	</div>
</div>
<div id="pager" class="clearfix"></div>
<!--_footer 作为公共模版分离出去--> 
<script type="text/javascript" src="../lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="./../static/js/common.js"></script>
<script type="text/javascript" src="../lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="../static/h-ui/js/H-ui.min.js"></script> 
<script type="text/javascript" src="../static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->
<link rel="stylesheet" type="text/css" href="../lib/pager/Pager.css"/>
<script type="text/javascript" src="../lib/pager/jquery.pager.js"></script>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="../lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="../lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="../lib/jquery.validation/1.14.0/messages_zh.js"></script> 
<script type="text/javascript">
	var adminName= parent.$("#adminName").val();
	$(function(){
	  if(adminName=="admin"){
	  		$("#updateTypeDiv")[0].style.display="block";
	  }
	});

	function updateAdminPwd(){
		if($("#oldPwd").val()==""){
			layer.msg("原始密码不允许为空！",{time:800});
			return false;
		}
		if($("#newPwd").val()==""){
			layer.msg("新密码不允许为空！",{time:1000});
			return false;
		}
		if($("#confirmNewPwd").val()==""){
			layer.msg("确认密码不允许为空！",{time:1000});
			return false;
		}
		if($("#oldPwd").val()==$("#newPwd").val()){
			layer.msg("新密码不能与原始密码相同！",{time:1000});
			return false;
		}
		var typePwd=$("#updateType").val();
		if($("#newPwd").val()==$("#confirmNewPwd").val()){
			var url="";
			if(adminName=="admin"){
				if(typePwd==0){
					url=admin_url+"/user/post/updateAdminPwd/"+$('#oldPwd').val()+"/"+$("#newPwd").val();
				}else{
					url=admin_url+"/user/post/updateAdminDealPwd/"+$('#oldPwd').val()+"/"+$("#newPwd").val();
				}
			}else{
				url=admin_url+"/user/post/updateAdminPwd/"+$('#oldPwd').val()+"/"+$("#newPwd").val();
			}
			$.ajax({
				type: "POST", //用post方式传输
			    xhrFields:{withCredentials:true},
			    data: {token:token,tokenUserId:userId},
			    url: url,
			    success: function (data) {
					var data = eval('('+data+')');
			    	if(data.status==3){
			    		layer.msg("原始密码不正确！",{time:1000});
			    		return false;
			    	}else if(data.status==1){
			    		layer.msg("修改成功！",{
			    			time:1000,
			    			end:function(){
			    				parent.window.location.href = "../index/login.html";
			    			}
			    		});
			    	}else if(data.status==2){
			    		layer.msg("修改失败！",{time:1000});
			    	}else if(data.status==0){
			    		layer.msg("修改异常！",{time:1000});
			    	}
				}
			});	
		}else{
			layer.msg("新密码与确认密码不相同！",{time:1000});
			return false;
		}
	}
</script>
</body>
</html>